package demo.DataStrucAndAlgo.SingletonPattern.Factory;

/**
 * @Auther: hjy(lc))
 * @Date: 2022/8/6-08-06-12:12
 * @Description：demo.DataStrucAndAlgo.SingletonPattern.Factory
 */
public class ShapeFactory {
    public Shape getShape(String shape){
        if(shape == null){
            return null;
        }
        //System.out.println(shape);
        if(shape.equalsIgnoreCase("circle")){
            return new Circle();
        }else if(shape.equalsIgnoreCase("Rectangle")){
            return new Rectangle();
        }else if(shape.equalsIgnoreCase("Square")){
            return new Square();
        }else{
            throw new RuntimeException("该工厂生成不了该对象");
        }
    }
}
